package com.qdxwx.data.service.user;

import com.qdxwx.data.mapper.user.UserThirdMapper;
import com.qdxwx.models.user.UserThird;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


/**
 * UserThird接口
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Service
public class UserThirdServiceImpl implements UserThirdService {
	private static final Logger logger = LoggerFactory.getLogger(UserThirdServiceImpl.class);

	@Autowired
	private UserThirdMapper userThirdMapper;

	/**
	 * 添加UserThird
	 *
	 * @param userThird 要添加的UserThird
	 * @return id
	 */
	@Override
	public int insert(UserThird userThird) {
		userThird.setLastTime(LocalDateTime.now());
		return userThirdMapper.addUserThird(userThird);
	}

	/**
	 * 根据id删除一个UserThird
	 *
	 * @param id 要删除的id
	 */
	@Override
	public void delete(int id) {
		if (id < 1) return;
		userThirdMapper.deleteUserThirdById(id);
	}

	/**
	 * 修改UserThird
	 *
	 * @param userThird 要修改的UserThird
	 */
	@Override
	public void update(UserThird userThird) {
		userThird.setLastTime(LocalDateTime.now());
		userThirdMapper.updateUserThird(userThird);
	}


	@Override
	public UserThird get(Long id) {
		return userThirdMapper.selectUserThirdById(id);
	}

	@Override
	public UserThird getByValue(String value) {
		return userThirdMapper.selectUserThirdByValue(value);
	}

	@Override
	public UserThird getWx(long userId) {
		return userThirdMapper.selectWxUserThirdByUserId(userId);
	}
	/**
	 * 根据userId获取单个UserThird对象
	 *
	 * @param userId 要查询的userId
	 * @return List<UserThird>
	 */
	@Override
	public List<UserThird> getListByUserId(long userId) {
		return userThirdMapper.selectUserThirdByUserId(userId);
	}

	/**
	 * 根据条件获取UserThird列表
	 *
	 * @param userThird 查询条件
	 * @return List<UserThird>
	 */
	@Override
	public List<UserThird> getList(UserThird userThird) {
		return userThirdMapper.selectUserThirdList(userThird);
	}

	@Override
	public int count(UserThird userThird) {
		return userThirdMapper.countUserThird(userThird);
	}
}